<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="format-detection" content="telephone=no" />
  <meta name="format-detection" content="email=no" />
  <title>举报弹窗</title>
  <link rel="stylesheet" href="../../css/api.css">
  <link rel="stylesheet" href="../../css/main.css">
  <link rel="stylesheet" href="../../css/vant.css">
  <style>
    html,
    body {
      background-color: transparent !important;
    }
  </style>
</head>

<body>
  <div class="app" v-cloak>
    <div class="opt-dialog-container">
      <div class="report">
        <van-popup v-model="isShowReportDialog" position="bottom" :style="{ height: '33%' }" @closed="onClosed">
          <van-row>
            <van-col>
              <van-field v-model="reportContent" rows="5" autosize type="textarea" placeholder="请输入举报内容及遇到的问题…"
                maxlength="200" />
            </van-col>
          </van-row>
          <van-row class="btn-container">
            <van-col>
              <van-button class="cancel-report report-btn" round color="#EDEDED" @click.stop="isShowReportDialog=false">
                取消
              </van-button>
            </van-col>
            <van-col>
              <van-button class="report-btn" round color="#3F8CEC" @click.stop="submitReport">确认</van-button>
            </van-col>
          </van-row>
        </van-popup>
      </div>
      <div class="share">
        <van-share-sheet class="iphonex-padding-bottom" @cancel="onClosed" @click-overlay="onClosed"
          v-model="shareDialog" :options="options" @select="onSelectShare" />
      </div>
    </div>

  </div>
  <script src="../../script/api.js "></script>
  <script src="../../script/flexible.js "></script>
  <script src="../../script/fastclick.js "></script>
  <script src="../../script/vue.min.js "></script>
  <script src="../../script/iconfont.js "></script>
  <script src="../../script/vant.min.js "></script>
  <script src="../../script/restful.js"></script>
  <script src="../../script/common.js"></script>
  <script src="../../script/businessCommon.js"></script>
  <script>
    apiready = function () {
      var vm = new Vue({
        el: '.app',
        data: {
          // 1表示举报弹框，2表示分享弹框
          type: api.pageParam.type,
          module: api.pageParam.module,
          id: api.pageParam.id,
          description: api.pageParam.description,
          topicType: api.pageParam.topicType, // 圈子详情类型
          userInfo: api.pageParam.userInfo, // 圈子详情用户信息

          reportContent: '',
          isShowReportDialog: false,

          shareDialog: false,

          options: [{
            name: '微信好友',
            icon: 'https://zzzzkj.oss-cn-shanghai.aliyuncs.com/static/tiexie/app/image/image/circle/wechat.png',
          }, {
            name: '微信朋友圈',
            icon: 'https://zzzzkj.oss-cn-shanghai.aliyuncs.com/static/tiexie/app/image/image/circle/Wechat_Moments.png'
          }],
        },
        mounted: function () {
          if (this.type == 1) {
            this.isShowReportDialog = true;
          } else {
            this.shareDialog = true;
          }
        },
        methods: {
          onClosed() {
            if (this.type == 1) {
              console.log('关闭frame...1')
              api.closeFrame({ name: 'report_alert' });
            } else {
              setTimeout(function () {
                console.log('关闭frame...2')
                api.closeFrame({ name: 'report_alert' });
              }, 300)
            }
          },
          submitReport() {
            if (!vm.reportContent) {
              toastBottom('请输入内容');
              return;
            }
            common("report")({
              content: vm.reportContent,
              targetId: vm.id,
              targetType: vm.module
            }, function (ret) {
              toastMiddle('您已经成功提交举报，平台会及时处理');
              vm.reportContent = '';
              vm.isShowReportDialog = false;
            })
          },
          toShare() {
            this.shareDialog = true;
          },
          onSelectShare(option, index) {
            common('getSystemSet')({}, function (ret) {
              const pcUrl = ret.data.pcUrl;
              const scene = index == 0 ? 'session' : 'timeline';
              var wxPlus = api.require('wxPlus');
              let contentUrl = '';
              if (vm.module == 'SELL_DEVICE' || vm.module == 'LEASE_DEVICE' || vm.module == 'PARTS') {
                contentUrl = pcUrl + '/product/h5/' + vm.id + '.html';
              } else if (vm.module == 'BUY_DEVICE' || vm.module == 'RENT_DEVICE') {
                contentUrl = pcUrl + '/equipment/h5/' + vm.id + '.html';
              } else if (vm.module == 'RECRUIT' || vm.module == 'JOB') {
                contentUrl = pcUrl + '/recruit/h5/' + vm.id + '.html';
              } else if (vm.module == 'FOR_CAR' || vm.module == 'FOR_GOODS') {
                contentUrl = pcUrl + '/logistics/h5/' + vm.id + '.html';
              } else if (vm.module == 'STORAGE') {
                contentUrl = pcUrl + '/storage/h5/' + vm.id + '.html';
              } else if (vm.module == 'MAINTENANCE') {
                contentUrl = pcUrl + '/maintenance/h5/' + vm.id + '.html';
              } else if (vm.module == 'INSURANCE') {
                contentUrl = pcUrl + '/insurance/h5/' + vm.id + '.html';
              } else if (vm.topicType == 'CIRCLEPIC') { // 圈子图片
                contentUrl = pcUrl + '/topicNew/h5/' + vm.id + '.html';
                vm.addTransteNum(vm.id) // 添加分享记录
              } else if (vm.topicType == 'CIRCLEVIDEO') { // 圈子视频
                contentUrl = pcUrl + '/topicNew/h5/' + vm.id + '.html';
                vm.addTransteNum(vm.id, vm.userInfo) // 添加分享记录
              } else if (vm.module == 'STEEL') { // 异型钢分享
                contentUrl = pcUrl + '/steel/h5/' + vm.id + '.html';
              } else if (vm.module == 'INVITE') {//
                contentUrl = pcUrl + '/h5/register' + '.html?' + "byPromoCode=" + vm.id;
              } else if (vm.module == 'WEBPAGE') {//静态H5
                contentUrl = vm.id;
              } else if (vm.module == 'NEWSDETAIL') {//资讯详情
                contentUrl = pcUrl + "/information/h5/" + vm.id + ".html";
                console.log(">>>"+contentUrl)
              }

              vm.shareDialog = false;
              vm.onClosed();
              wxPlus.shareWebpage({
                scene: scene,
                title: scene === 'session' ? '【铁蟹网】机械设备一站式服务平台！' : (vm.description ? vm.description : '【铁蟹网】机械设备一站式服务平台！'),
                description: vm.description ? vm.description : '',
                thumb: 'widget://image/share/share.png',
                contentUrl: contentUrl
              }, function (ret, err) {
                toastBottom('分享成功~');
              });

            })

          },

          // 记录 发现- 动态转发量
          addTransteNum(topicId, userInfo) {
            fnPut(interfaces.CONTENT_MODULE.CIRCLE.RECORD_SHARE_NUM + "/" + topicId, {},
              false,
              function (ret, err) {
                if (ret && ret.code === RESPONSE_OK) {
                  //toastMiddle('转发记录添加成功')
                  api.sendEvent({
                    name: 'addShareRecordSuccess',
                    extra: {
                      topicId,
                      userInfo
                    }
                  })
                }
                // toastBottom(ret ? ret.msg : '');
              }
            )
          }
        },
      })
    }
  </script>
</body>

</html>